import request from '@/sheep/request';

const ScheduleBookingApi = {
  // 创建学员预约记录
  createScheduleBooking: (data) => {
    return request({
      url: '/schedule-booking/create',
      method: 'POST',
      data,
      custom: {
        showLoading: true,
        loadingMsg: '正在提交预约...',
        showSuccess: false, // 不自动显示成功提示，由业务代码控制
        showError: false,   // 不自动显示错误提示，由业务代码控制
        auth: true,
      },
    });
  },

  // 获取学员预约记录列表（用户端）
  getScheduleBookingPage: (params) => {
    return request({
      url: '/schedule-booking/page',
      method: 'GET',
      params,
      custom: {
        showLoading: false,
        auth: true,
      },
    });
  },

  // 获取学员预约记录详情
  getScheduleBooking: (id) => {
    return request({
      url: `/schedule-booking/get?id=${id}`,
      method: 'GET',
      custom: {
        showLoading: false,
        auth: true,
      },
    });
  },

  // 更新学员预约记录
  updateScheduleBooking: (data) => {
    return request({
      url: '/schedule-booking/update',
      method: 'PUT',
      data,
      custom: {
        showLoading: true,
        loadingMsg: '正在更新...',
        showSuccess: true,
        successMsg: '更新成功',
        auth: true,
      },
    });
  },

  // 删除学员预约记录
  deleteScheduleBooking: (id) => {
    return request({
      url: `/schedule-booking/delete?id=${id}`,
      method: 'DELETE',
      custom: {
        showLoading: true,
        loadingMsg: '正在删除...',
        showSuccess: true,
        successMsg: '删除成功',
        auth: true,
      },
    });
  },

  // 查询教练可预约人数
  getCoachAvailability: (params) => {
    return request({
      url: '/schedule-booking/coach-availability',
      method: 'GET',
      params,
      custom: {
        showLoading: false,
        auth: true,
      },
    });
  },
};

export default ScheduleBookingApi;
